<taglib name="Admin\TagLib\EasyUI" />

<easyui:datagrid options="datagrid.options" fields="datagrid.fields" />

<!--添加岗位 -->
<div id="keyword_keywordlist_add_dialog" class="easyui-dialog" title="添加岗位"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_view_detail',
     buttons:[{text:'关闭',iconCls:'icons-arrow-cross',
     handler:function(){$('#keyword_keywordlist_add_dialog').dialog('close');}}]"
     style="width:450px;height:250px;"></div>

<!--编辑岗位 -->
<div id="keyword_keywordlist_edit_dialog" class="easyui-dialog" title="编辑岗位"
     data-options="modal:true,closed:true,iconCls:'icons-application-application_view_detail',
     buttons:[{text:'关闭',iconCls:'icons-arrow-cross',
     handler:function(){$('#keyword_keywordlist_edit_dialog').dialog('close');}}]"
     style="width:450px;height:330px;"></div>




<script type="text/javascript">
    var keyword_keywordlist_datagrid_toolbar = [
        { text: '添加词汇', iconCls: 'icons-table-table_add', handler: keywordadd },
        { text: '刷新', iconCls: 'icons-table-table_refresh', handler: keywordKeywordRefresh }
    ];

    //操作格式化
    function keywordOperateFormatter(val){
        var btn = [];
        btn.push('<a href="javascript:;" onclick="keywordEdit('+val+')">编辑</a>');
        /*btn.push('<a href="javascript:;" onclick="missionBlack('+val+')">拉黑/启用</a>');*/
        btn.push('<a href="javascript:;" onclick="keywordDelete('+val+')">删除</a>');
        return btn.join(' | ');
    }
    function keywordadd(){

        var url = '<{:U('Keyword/keywordAdd')}>';

        $('#keyword_keywordlist_add_dialog').dialog({href:url});
        $('#keyword_keywordlist_add_dialog').dialog('open');

    }
    //刷新
    function keywordKeywordRefresh(){
        $('#keyword_keywordlist_datagrid').datagrid('reload');
    }

    function keywordEdit(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择', 'error');
            return false;
        }
        var url = '<{:U('Keyword/keywordEdit')}>';
        url += url.indexOf('?') != -1 ? '&id='+id : '?id='+id;
        $('#keyword_keywordlist_edit_dialog').dialog({href:url});
        $('#keyword_keywordlist_edit_dialog').dialog('open');

    }


    function keywordDelete(id){
        if(typeof(id) !== 'number'){
            $.messager.alert('提示信息', '未选择', 'error');
            return false;
        }
        $.messager.confirm('提示信息', '确定要删除吗？', function(result){
            if(!result) return false;
            $.post('<{:U('Keyword/keywordDelete')}>', {id: id}, function(res){
                if(!res.status){
                    $.messager.alert('提示信息', res.info, 'error');
                }else{
                    $.messager.alert('提示信息', res.info, 'info');
                    keywordKeywordRefresh();
                }
            }, 'json');
        });
    }


    function keywordStatusFormatter(val){
        switch(val)
        {
            case "1":
                return "发布中 ";

            case "2":
                return "未发布";

            default:
                return "未定义 ";
        }
    }



</script>